package com.chentf.behavioral.strategy.code.a;

import com.chentf.behavioral.strategy.code.a.impl.BubbleSortStrategy;
import com.chentf.behavioral.strategy.code.a.impl.QuickSortStrategy;

/**
 * 模版方法定义大框架，策略模式定义小细节
 */
public class Client {
    public static void main(String[] args) {
        Integer[] arr = new Integer[]{2, 1, 10, 4, 6, 8, 7, 5, 9, 3};

        SortService sortService = new SortService(new BubbleSortStrategy());
        sortService.sort(arr);

        System.out.println("------------------");

        // 更新策略
        sortService.setSortStrategy(new QuickSortStrategy());
        sortService.sort(arr);
    }
}
